/*
* @Author: luocheng
* @Date:   2020-01-08 22:12:53
* @Last Modified by:   luocheng
* @Last Modified time: 2020-01-12 12:07:20
*/
const paginationBev = Behavior({
	data: {
		dataArray: [],
		total: null,
		noneResult: false
	},
	methods: {
		// 获取到新数据后，将新旧数据合并后赋值给原始数组
		setMoreData(dataArray){
			const tempArray = this.data.dataArray.concat(dataArray)
			this.setData({
				dataArray: tempArray
			})
		},
		// 获取发送数据请求的开始索引值
		getCurrentStart(){
			return this.data.dataArray.length
		},

		setTotal(total){
			this.data.total = total
			if (total == 0) {
				this.setData({
					noneResult: true
				})
			}
		},
		// 是否还有更多数据可加载
		hasMore(){
			if (this.data.dataArray.length >= this.data.total) {
				return false
			} else {
				return true
			}
		},
		// 清空搜索结果
		empty(){
			this.setData({
				dataArray: [],
				total: null,
				noneResult: false
			})
		}
	}
})

export {paginationBev}